package com.yoga.app.web;

import com.yoga.app.annotation.LoginUser;
import com.yoga.common.appexception.AppException;
import com.yoga.common.appexception.YogaResult;
import com.yoga.common.bo.PhotoAlbumBO;
import com.yoga.common.bo.YogaAdminBO;
import com.yoga.common.bo.YogaUserBO;
import com.yoga.common.page.PageBO;
import com.yoga.common.qto.PhotoAlbumQTO;
import com.yoga.manager.admin.AdminPhotoAlbumManager;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Created by hdx on 2020/10/20.
 */
@RestController
@RequestMapping("${basePath}")
public class AppPhotoAlbumController {

    @Resource
    private AdminPhotoAlbumManager photoAlbumManager;

    @GetMapping("/photo/findById")
    public YogaResult<PhotoAlbumBO> findData(@LoginUser YogaUserBO userBO, Long photoAlbumId) throws AppException {
        PhotoAlbumBO result = photoAlbumManager.findById(photoAlbumId);

        return new YogaResult<>(result);
    }


    @PostMapping("/photo/findList")
    public YogaResult<PageBO<PhotoAlbumBO>> findData(@LoginUser YogaUserBO userBO, @RequestBody PhotoAlbumQTO photoAlbumQTO) throws AppException {
        PageBO<PhotoAlbumBO> result = photoAlbumManager.findForPage(photoAlbumQTO);

        return new YogaResult<>(result);
    }

}
